
#ifndef APP_SLAVE_DEVICE_H
#define APP_SLAVE_DEVICE_H

#include "stdint.h"

typedef struct
{
    uint16_t srcTable;
    uint16_t paraTable;
}ResourceCrc;

#pragma pack(1)

/* 设备信息类参数 */
typedef struct
{
	char name[33]; //设备名称
	char os[28]; //操作系统，"freeRTOS10.2.0.1"
    char buildVersion[33]; //编译版本
	uint16_t svCRC; //软件校验码，156F
}device_slave_para_info_t;


typedef struct
{
    uint8_t valid;
	float value;
}device_slave_meter_t;

//------------------------多功能焊台------------------------------------------
enum {
    kSolderType_Disconnect =0,
    kSolderType_T12,
    kSolderType_C245,
    kSolderType_C210,
    kSolderType_Unknow,
};

//后期需要修改，用兼容方式通讯

#define MHT_SRC_TABLE_METER_ITEM_NUM		(11)
enum
{
    kMHT_MeterPowerV = 0,
    kMHT_MeterPowerI,
    kMHT_MeterPowerPower,
    kMHT_MeterNtcTemp,
    kMHT_MeterSolderTemp,
    kMHT_MeterSolderPower,
    kMHT_MeterSolderI,
    kMHT_MeterGunTemp,
    kMHT_MeterPlateTemp,
    kMHT_MeterPowerOutV,
    kMHT_MeterPowerOutI,
};

/* 设备存储类参数 */
typedef struct
{
    uint8_t solder_auto_enable; //开机自动启动
    uint16_t solder_set_temp;
    uint8_t solder_sleep_time; //分钟
    uint16_t solder_sleep_temp;
    //uint16_t solder_set_temp;
}device_mht_para_store_t;

/* 设备运行类参数 */
typedef struct
{
    uint8_t solder_enable; //使能烙铁输出
    uint16_t solder_temp;
    uint8_t plate_enable;
    uint16_t plate_temp;
    uint8_t gun_enable; //使能热风枪输出
    uint16_t gun_temp;
    uint8_t gun_fan_gear;
    uint8_t power_enable; //使能电源输出
    uint16_t power_set_u; //电源电压设置 mV
    uint16_t power_set_i; //电源电压设置 mA
}device_mht_para_run_t;

typedef struct
{
    uint8_t solder_type;
    uint8_t solder_work;
    uint8_t gun_work;
    uint8_t plate_work;
    uint8_t power_work;
}device_mht_para_status_t;
  
typedef struct
{
    device_mht_para_store_t store;
    device_slave_para_info_t info;
    device_mht_para_run_t run;
    device_mht_para_status_t status;
}device_mht_para_t;



typedef union
{
    uint8_t value;
    struct {
        uint8_t para_store:1;
        uint8_t para_info:1;
        uint8_t para_run:1;
        uint8_t para_status:1;
        
    };
}device_mht_change_t;

#pragma pack()

typedef struct
{
    device_slave_meter_t meter[MHT_SRC_TABLE_METER_ITEM_NUM]; //测量数据
    device_mht_para_t para;
    uint8_t connect; //连接标识
    device_mht_change_t change_flag;
    uint8_t write_para_flag; //写参数标识
}app_mht_device_t;

extern app_mht_device_t app_slave_dev_mht;

#endif
